<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>套餐添加/修改</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base2.css,base_new.css'); }
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,choose.js,DatePicker/WdatePicker.js,product_add.js,imageup.js,jquery.validate.js"); }
    {php echo Common::getCss('uploadify.css','js/uploadify/'); }
</head>
<body>
<table class="content-tab">
    <tr>
        <td width="119px" class="content-lt-td" valign="top">
            {template 'stourtravel/public/leftnav'}
            <!--右侧内容区-->
        </td>
        <td valign="top" class="content-rt-td">
            <form method="post" name="product_frm" id="product_frm">

                <div class="cfg-header-bar" id="nav">
                    <div class="cfg-header-tab">
                        <span class="item on"><s></s>{$position}</span>
                    </div>
                    <a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10"
                       onclick="window.location.reload()">刷新</a>
                </div>

                <!--基础信息开始-->
                <div class="product-add-div">
                    <ul class="info-item-block">
                        <li>
                            <span class="item-hd">当前产品：</span>
                            <div class="item-bd">
                                <span class="item-text">{$productname}</span>
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">套餐名称：</span>
                            <div class="item-bd">
                                <input type="text" name="suitname" id="suitname" class="input-text w700" value="{$info['suitname']}"/>
                            </div>
                        </li>
<!--                        <li>-->
<!--                            <span class="item-hd">邮寄地址：</span>-->
<!--                            <div class="item-bd">-->
<!--                                <label class="radio-label">-->
<!--                                    <input type="radio" name="mailing_address" value="0" {if empty($info['mailing_address'])}checked="checked"{/if} />需要-->
<!--                                </label>-->
<!--                                <label class="radio-label ml-20">-->
<!--                                    <input type="radio" name="mailing_address" value="1" {if $info['mailing_address']=='1'}checked="checked"{/if} />不需要-->
<!--                                </label>-->
<!--                            </div>-->
<!--                        </li>-->
                    </ul>
                    {template 'stourtravel/public/price'}
                    <ul class="info-item-block">
                        <li>
                            <span class="item-hd">套餐说明：</span>
                            <div class="item-bd">
                                {php Common::getEditor('suitdescription',$info['description'],$sysconfig['cfg_admin_htmleditor_width'],120,'Line');}
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">支付方式：</span>
                            <div class="item-bd">
                                <div class="on-off">
                                    <label class="radio-label">
                                        <input type="radio" name="paytype" value="1" {if $info['paytype']=='1'}checked="checked"{/if} />全款支付 &nbsp;
                                    </label>
                                    <label class="radio-label ml-20">
                                        <input type="radio" name="paytype" value="2" {if $info['paytype']=='2'}checked="checked"{/if} />定金支付 &nbsp;
                                    </label>
                                    <span id="dingjin" style="{if $info['paytype'] == '2'}display:inline-block{else}display: none{/if}">
                                        <input type="text" name="dingjin" id="dingjintxt" class="input-text w60" value="{$info['dingjin']}" size="8" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-\.]+/,'');}).call(this)" onblur="this.v();">&nbsp;元
                                    </span>
                                    <label class="radio-label ml-20">
                                        <input type="radio" name="paytype" value="3" {if $info['paytype']=='3'}checked="checked"{/if} />二次确认支付 &nbsp;
                                    </label>
                                    <script>
                                        $("input[name='paytype']").click(function () {
                                            if ($(this).val() == 2) {
                                                $("#dingjin").show();
                                            } else {

                                                $("#dingjin").hide()
                                            }
                                        })
                                    </script>
                                </div>
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">退款类型{Common::get_help_icon('product_refund_restriction_type')}：</span>
                            <div class="item-bd">
                                <label class="radio-label">
                                    <input type="radio" name="refund_restriction" value="0" {if empty($info['refund_restriction'])}checked="checked"{/if} />可退
                                </label>
                                <label class="radio-label ml-20">
                                    <input type="radio" name="refund_restriction" value="1" {if $info['refund_restriction']=='1'}checked="checked"{/if} />不可退
                                </label>
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">待付款时限{Common::get_help_icon('order_auto_close_time')}：</span>
                            <div class="item-bd">
                                <input type="text" name="auto_close_time_hour" id="auto_close_time_hour" maxlength="2" onkeyup="value=value.replace(/[^\d]/g,'')" class="input-text w60" {if $action=='add'}value="0"{else}value="{$info['auto_close_time_hour']}"{/if}>&nbsp;小时
                                <input type="text" name="auto_close_time_minute" id="auto_close_time_minute" maxlength="2" onkeyup="value=value.replace(/[^\d]/g,'')" class="input-text w60" {if $action=='add'}value="0"{else}value="{$info['auto_close_time_minute']}"{/if}>&nbsp;分钟
                            </div>
                        </li>
                        <li>
                            <span class="item-hd">门市价：</span>
                            <div class="item-bd">
                                <input type="text" name="sellprice" id="sellprice" class="input-text w100 reset-input" value="{$info['sellprice']}"/>
                                <span class="item-text ml-5">元</span>
                            </div>
                        </li>
                    </ul>
                    <div class="line"></div>
                </div>
                <!--/基础信息结束-->

                <div class="clear clearfix pb-20" style="padding-left: 10px; " id="hidevalue">
                    <input type="hidden" name="suitid" id="suitid" class="public_suit_id" value="{$info['id']}"/>
                    <input type="hidden" name="action" id="action" value="{$action}"/>
                    <input type="hidden" name="productid" id="productid" value="{$productid}">
                    <input type="hidden" name="pricerule" id="pricerule" value="{$info['lastoffer']['pricerule']}"/>
                    <a class="btn btn-primary radius size-L ml-115" id="btn_save" href="javascript:;">保存</a>
                </div>

            </form>
        </td>
    </tr>
</table>

<script>
    var typeid = "{$typeid}";
    $(document).ready(function () {
        //验证
        $('.reset-input').keyup(function () {
            var value = $(this).val();
            value = value.replace(/[^\d.]/g, "");//清除“数字”和“.”以外的字符
            value = value.replace(/^\./g, "");//验证第一个字符是数字而不是.
            value = value.replace(/\.{2,}/g, ".");//只保留第一个. 清除多余的.
            value = value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
            value = value.replace(/([0-9]+\.[0-9]{2})[0-9]*/, "$1");
            $(this).val(value);
            if ($(this).attr('name') == 'basicprice' || $(this).attr('name') == 'profit') {
                var dd = $(this).parents('td:first');
                var tprice = 0;
                dd.find('input:text').each(function (index, element) {
                    var price = $(element).val();
                    if (!isNaN(price))
                        tprice = ST.Math.add(price, tprice);
                });
                dd.find(".tprice").html("¥" + tprice);
            }
        });

        //保存
        $("#btn_save").click(function () {
            var suitname = $("#suitname").val();
            if (suitname == '') {
                ST.Util.showMsg('请输入套餐名称', 5, 1000);
                return false;
            }

            $.ajaxform({
                url: SITEURL + "tongyong/ajax_suit_save",
                method: "POST",
                isUpload: true,
                form: "#product_frm",
                dataType: 'json',
                success: function (data) {

                    if (data.status) {
                        if (data.suitid != null) {
                            $("#suitid").val(data.suitid);
                        }
                        ST.Util.showMsg('保存成功!', '4', 2000);
                    }
                }
            });
        })
    });
</script>
</body>
</html>